﻿using System;
using System.Collections.Generic;
using System.Text;

namespace Pahan.McuFusion.Common.Utils
{
    public static class CollectionHelper
    {
        public static T[] ToArray<T>(ICollection<T> collection)
        {
            if (collection == null)
            {
                return null;
            }
            if (collection is T[])
            {
                return collection as T[];
            }
            var array = new T[collection.Count];
            int i = 0;
            foreach (var item in collection)
            {
                array[i++] = item;
            }
            return array;
        }
    }
}
